package cn.jiyun.controller;


import cn.jiyun.common.config.Result;
import cn.jiyun.entity.XmOrder;
import cn.jiyun.entity.XmRefund;
import cn.jiyun.service.IXmOrderService;
import cn.jiyun.service.IXmRefundService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author author
 * @since 2024-11-27
 */
@RestController
@RequestMapping("/xm-trade/xm-refund")
public class XmRefundController {
    @Autowired
    private IXmRefundService xmRefundService;
    @Autowired
    private IXmOrderService xmOrderService;

    @RequestMapping("/save")
    public Result save(@RequestBody XmRefund xmRefund){
        XmOrder xmOrder = xmOrderService.list(new LambdaQueryWrapper<XmOrder>().eq(XmOrder::getId, xmRefund.getOid())).get(0);
        xmOrder.setJid(2);
        xmOrderService.updateById(xmOrder);
        xmRefund.setCreatetime(LocalDateTime.now());
        xmRefundService.save(xmRefund);
        return Result.ok();
    }
}
